package com.example.mouther_bg.utils;

import lombok.Data;

import java.io.Serializable;

@Data
public class Result implements Serializable {
    private int code;   //200正常，否则数据异常
    private String massage;
    private Object data;
    private String token;
//成功返回状态码
    public static Result succ(Object data){
        return succ(200,"操作成功",data);
    }
    public static Result succ(int code, String massage,Object data){
        Result result = new Result();
        result.setCode(code);
        result.setData(data);
        result.setMassage(massage);
        return result;
    }
//    失败返回状态码
    public static Result err(){
        return err(400,"请求错误");
    }
    public static Result err(int code,String massage){
        Result result = new Result();
        result.setCode(code);
        result.setMassage(massage);
        return result;
    }

//    token成功
    public static Result tokenSucc(String token){
        Result result = new Result();
        result.setCode(200);
        result.setMassage("操作成功");
        result.setToken(token);
        return result;
    }
//
//    token错误


    public static Result tokenErr(int code,String message){
        Result result = new Result();
        result.setCode(code);
        result.setMassage(message);
        return result;
    }

}
